#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>

using std::cin;
using std::cout;
using std::vector;
using std::endl;

#define magic 268435459;

template<typename T>
void Input(vector<vector<T>> & table, vector<vector<T>> &count) {
    size_t n, m;
    cin >> n >> m;
    table.resize(n), count.resize(n);
    for (size_t i = 0; i < n; ++i) {
        for (size_t j = 0; j < m; ++j) {
            T next;
            cin >> next;
            table[i].push_back(next);
            count[i].push_back(0);
        }
    }
    count[0][0] = table[0][0];

    for (size_t i = 1; i < m; ++i) {
        if (table[0][i]) {
            count[0][i] = count[0][i - 1];
        }
    }

    for (size_t i = 1; i < n; ++i) {
        if (table[i][0]) {
            count[i][0] = count[i - 1][0];
        }
    }
}

template<typename T>
void Solution(const vector<vector<T>> & table, vector<vector<T>> &count) {
    for (int i = 1; i < count.size(); ++i) {
        for (int j = 1; j < count[i].size(); ++j) {
            if (table[i][j]) {
                count[i][j] = (count[i - 1][j] + count[i][j - 1]) % magic;
            }
        }
    }
    cout << count[count.size() - 1][count[count.size() - 1].size() - 1];
}

int main() {
    vector<vector<long long>> table;
    vector<vector<long long>> count;
    Input(table, count);
    Solution(table, count);
}